unit F_RMateria;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, F_ABM_Materias, DB, ZAbstractRODataset, ZDataset,
  JvComponentBase, JvFormPlacement, Grids, DBGrids, JvExDBGrids, JvDBGrid,
  JvDBUltimGrid, DBCtrls, StdCtrls, JvExControls, JvSpeedButton, ExtCtrls;

type
  TF_RMaterias = class(TABM_Materias)
    JvSB_CrearReporte: TJvSpeedButton;
    procedure JvSB_CrearReporteClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  F_RMaterias: TF_RMaterias;

implementation

uses R_DocumentosPorMateria;

{$R *.dfm}

procedure TF_RMaterias.JvSB_CrearReporteClick(Sender: TObject);
var
  i: integer;
  Aux: string;
begin
  inherited;
  if JvDBUltimGrid.SelectedRows.Count > 0 then
  begin
    with JvDBUltimGrid.DataSource.DataSet do
    begin
      for i := 0 to JvDBUltimGrid.SelectedRows.Count-1 do
      begin
        GotoBookmark(Pointer(JvDBUltimGrid.SelectedRows.Items[i]));
        Aux:= Aux+FieldByName('id').AsString+', ';
      end;
    end;
    Aux:= Copy(Aux, 1, Length(Aux)-2);

    with TFR_DocumentosPorMateria.Create(Self, Aux) do
    try
      Reporte.Preview;
    finally
      Reporte.Free;
    end;

  end;
end;

end.
